package design.pattern.singleton.threadlocal;

/**
 * @description:
 * @author: liuzhangcheng
 **/
public class ThreadLocalSingletonTest {
    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            System.out.println(ThreadLocalSingleton.getInstance());
        }

        Runnable runnable = ()->{
            ThreadLocalSingleton singleton = ThreadLocalSingleton.getInstance();
            System.out.println(Thread.currentThread().getName() + ":" + singleton);
        };

        Thread t1 = new Thread(runnable);
        Thread t2 = new Thread(runnable);

        t1.start();
        t2.start();
        System.out.println("------end-------");
    }
}
